package com.DreamTeam.dbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class MySqlConnection {
	private Connection conn;
	private final String DBURL = "jdbc:mysql://id4.free.yunhosting.com:3306/szplss525?useUnicode=true&characterEncoding=utf-8";
	//private final String DBURL = "jdbc:mysql://localhost:3306/szplss525?useUnicode=true&characterEncoding=utf-8";
	private final String USER = "szplss525";
	private final String PASSWORD = "123123";

	public MySqlConnection() {
		try {
			Class.forName("com.mysql.jdbc.Driver");
			conn = DriverManager.getConnection(DBURL, USER, PASSWORD);
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

	public Connection getConnection() {
		return this.conn;
	}

	public boolean closeConnection() {
		if (conn != null) {
			try {
				conn.close();
				return true;
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return false;
	}

}
